package com.auntvt.timo.jpax.core.quick.node;

import com.auntvt.timo.jpax.core.quick.enums.CriteriaType;
import com.auntvt.timo.jpax.core.quick.matcher.AbstractMatcher;
import lombok.Data;

import java.util.List;
import java.util.function.Consumer;

/**
 * 匹配条件规则节点
 */
/**
 * 匹配条件类型
 *
 * @author 小懒虫 <auntvt@163.com>
 * @date 2021/7/31
 */
@Data
public class MatcherNode {

    /**
     * Consumer类
     */
    Consumer<? extends AbstractMatcher> consumer;
    /**
     * 字段名称
     */
    private String fieldName;
    /**
     * 条件类型
     */
    private CriteriaType type;
    /**
     * 节点值
     */
    private Object value;
    /**
     * 子节点集合
     */
    private List<MatcherNode> children;

    public MatcherNode() {
    }

    public MatcherNode(String fieldName, CriteriaType type) {
        this.fieldName = fieldName;
        this.type = type;
    }

    public MatcherNode(String fieldName, CriteriaType type, Consumer<? extends AbstractMatcher> consumer) {
        this.fieldName = fieldName;
        this.type = type;
        this.consumer = consumer;
    }
}